<?php View::render('admin/layouts/meta');?>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 商家管理
    <span class="c-gray en">&gt;</span> 经营城市
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <form>
        <div class="text-c">
            <span class="select-box" style="width:150px">
                <select class="select" name="province">
                    <option value="">--搜索省--</option>
                    <?php foreach ($province_list as $value) {?>
                    <option value="<?php echo $value['id']; ?>" <?php if ($value['id'] == $province) {echo 'selected="selected"';}?>>==<?php echo $value['name']; ?>==</option>
                    <?php } ?>
                </select>
            </span>
            <span class="select-box" style="width:150px">
                <select class="select" name="city">
                    <option value="">--搜索城市--</option>
                    <?php foreach ($city_list as $value) {?>
                        <option value="<?php echo $value['id']; ?>" <?php if ($value['id'] == $city) {echo 'selected="selected"';}?>>==<?php echo $value['name']; ?>==</option>
                    <?php } ?>
                </select>
            </span>
            <span class="select-box" style="width:150px">
                <select class="select" name="area">
                    <option value="">--搜索地区--</option>
                    <?php foreach ($area_list as $value) {?>
                        <option value="<?php echo $value['id']; ?>" <?php if ($value['id'] == $area) {echo 'selected="selected"';}?>>==<?php echo $value['name']; ?>==</option>
                    <?php } ?>
                </select>
            </span>
            <input type="hidden" name="page" value="1"/>
            <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
    </form>
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" onclick="formAlert('添加经营城市','<?php echo Router::getBaseUrl(); ?>/admin_business/edit', '80%','80%')" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 添加经营城市
            </a>
        </span>
        <span class="r">共有数据：<strong><?php echo count($list); ?></strong> 条</span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="50">ID</th>
                <th width="150">省</th>
                <th width="150">市</th>
                <th width="150">地区</th>
                <th width="200">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if ($list) {
                foreach ($list as $info) {?>
                    <tr class="text-c">
                        <td><?php echo $info['id']; ?></td>
                        <td><?php echo $info['province_name']; ?></td>
                        <td><?php echo $info['city_name']; ?>
                            <a href="javascript:;" onclick="formAlert('编辑','<?php echo Router::getBaseUrl(); ?>/admin_business/edit?id=<?php echo $info['id']; ?>','100%','100%')" style="text-decoration:none" >（新增/查看）</a>
                        </td>
                        <td><?php echo $info['area_name']; ?></td>
                        <td class="td-manage">
                            <a href="javascript:;" rel="<?php echo $info['id']; ?>" style="text-decoration:none"  class="ml-5 j_del">删除</a>
                        </td>
                    </tr>
                <?php }}?>
            </tbody>
        </table>
        <div>
            <?php echo $pageHtml; ?>
        </div>
    </div>
</div>
</body>
<?php View::render('admin/layouts/footer');?>
<script type="text/javascript">
    $(function(){
        window.formAlert = function(title, url, w, h) {
            layer.open({
                type: 2,
                title: title,
                area: [w, h],
                content: url,
                end: function(){
                    window.location.href=location.href;
                }
            });
        }

        $('.j_del').click(function(){
            var id = $(this).attr('rel');
            $.post('<?php echo Router::getBaseUrl(); ?>/admin_business/comDelete', {id:id}, function (result) {
                if (result.status == 200) {
                    var r=confirm(result.msg);
                    if (r==true)
                    {
                        $.post('<?php echo Router::getBaseUrl(); ?>/admin_business/delete', {id:id}, function (result) {
                            if (result.status == 200) {
                                layer.msg(result.msg, {
                                    icon: 1,
                                    skin: 'u-msg',
                                    time: 1800,
                                },function() {
                                    window.location.href = location.href;
                                    return true;
                                });
                            }else{
                                layer.msg(result.msg, {
                                    icon: 0,
                                    skin: 'u-msg',
                                    time: 2200,
                                });
                            }
                        }, 'json');
                    }
                }else{
                    layer.msg(result.msg, {
                        icon: 0,
                        skin: 'u-msg',
                        time: 2200,
                    });
                }
            }, 'json');
            return;
        });
    });
</script>
</html>
